package com.zt.ztzx.controller;

import com.github.pagehelper.PageInfo;
import com.zt.ztzx.model.entity.product.Category;
import com.zt.ztzx.model.vo.common.Result;
import com.zt.ztzx.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    //获取用户

    @GetMapping("/findAll/{pageNum}/{pageSize}")
    @Operation(summary = "商品分类列表", description = "商品分类列表",method = "findAll方法")
    @Parameters({
            @Parameter(name = "sysUserDto",description = "商品查询条件",required = true),
            @Parameter(name = "pageNum",description = "当前页码",required = true),
            @Parameter(name = "pageSize",description = "每页显示条数",required = true)
    })
    public Result<PageInfo<Category>> findAll(Category category, @PathVariable("pageNum")Integer pageNum, @PathVariable("pageSize")Integer pageSize){
        return categoryService.findAll(category,pageNum,pageSize);
    }


    @DeleteMapping("/remove")
    @Operation(summary = "删除商品分类",description = "删除分类",method = "remove方法")
    @Parameters({
            @Parameter(name = "id",description = "分类id",required = true)
    })
    public Result remove(Integer id) {
        return categoryService.removeData(id);
    }
}
